﻿using MassTransit;
using System;
using System.Collections.Generic;
using System.Text;

namespace Finbook.Entity.Cmds
{
    public class TestRequestObserver
        : IObserver<ConsumeContext<TestRequest>>
    {
        public void OnCompleted()
        {
            Console.WriteLine("//***************");
            Console.WriteLine($"//******{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}Completed.");
            Console.WriteLine("//***************");
        }

        public void OnError(Exception error)
        {
            Console.WriteLine("//***************");
            Console.WriteLine($"//******{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}Error.");
            Console.WriteLine("//***************");
        }

        public void OnNext(ConsumeContext<TestRequest> value)
        {
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("//***************");
            Console.WriteLine($"//******{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}观察到消息{value.Message.Name}.");
            Console.WriteLine("//***************");
            Console.ForegroundColor = ConsoleColor.White;
        }
    }
}
